package com.zr.daoimpl;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.zr.dao.ShowGuoFanPriceDao;
import com.zr.model.Cdisstation;
@Repository("shgufaprdaim")
public class ShowGuoFanPriceDaoImpl<T> extends BaseDaoImpl<T> implements ShowGuoFanPriceDao<T>{

	@Override
	public List<Cdisstation> findFanPrice(int page, int rows, int uid) {
		String hql="from Cdisstation as cd where cd.cuser.uid=:uid";
		Query query=this.getCurrentSession().createQuery(hql);
		//Query query=this.getSessionFactory().openSession().createQuery(hql);
		query.setInteger("uid", uid);
		query.setFirstResult((page-1)*rows);
		query.setMaxResults(rows);
		
		List<Cdisstation>li=query.list();
		return li;
	}

	@Override
	public int getcount() {
		String hql="select count(cd.disid) from Cdisstation as cd";
		
		Query query=this.getSessionFactory().openStatelessSession().createQuery(hql);
		int i=((Number)query.uniqueResult()).intValue();
		return i;
	}

}
